function checkdiseas(diseas) {
	switch (diseas) {
	case "痛風":
		return "C1";
	case "胃炎":
		return "C2";
	case "高血脂":
		return "C3";
	case "泌尿系統結石":
		return "C4";
	case "中風":
		return "C5";
	case "糖尿病":
		return "C6";
	case "肝炎":
		return "C7";
	case "甲狀腺機能亢進":
		return "C8";
	case "腎臟病":
		return "C9";
	case "心臟病":
		return "C10";
	case "蠶豆症":
		return "C11";
	case "膽固醇過高":
		return "C12";
	case "肝硬化":
		return "C13";
	case "高血壓":
		return "C14";
	case "消化性潰瘍":
		return "C15";
	case "癌症治療中":
		return "C16";
	case "癌症治癒":
		return "C17";
	}
}
//-----------------------------------------------------------------------
function ClearStatus() { //全部選取預設為false
	var count = document.getElementById("count").value;
	for (var i=1;i<=count ;i++){
		document.getElementById("C"+i).checked = false;
		document.getElementById("label"+i).className = "off";
		document.getElementById("year"+i).className = "off";
	}
}
// -----------------------------------------------------------------------
function getcase() {  //讀取疾病史

	if ($("#personId").val().length < 10){
		$("#personId").val("");
		ClearStatus();
		return;
	}else{
		if(checkID($("#personId").val())){
			$.ajax({
				type : "POST",
				url : "readcaseHistory.do",
				dataType : 'text',


				data : {
					personId : $("#personId").val()
				},

				error : function(xhr) {
					alert("Ajax request error!");

				},
				
				success : function(DataList) {
					ClearStatus();
					var checkName = "";
					var diseas_temp = DataList.split(",");
					for (i in diseas_temp) {
						checkName = checkdiseas(diseas_temp[i]);
						document.getElementById(checkName).checked = true;
					}	
				}
			});
		}		
		else{
			$("#personId").val("");
			ClearStatus();
			return;
		}
	}	
}